module HibTeX.PrettyPrinter where

import HibTeX.Parser

prettyV :: BibTeXType -> String 
prettyV (BComment s) = "Comment: " ++ s
prettyV (BEntity name id list) = "Entity " ++ name ++"("++id++"): \n\t" ++ ( value list)
	where   value [] = ""
		value ((BibValue k v):xs) = "\t"++k ++ ": " ++ v ++ "\n" 


prettyV' :: BibTeXType -> String
prettyV' (BComment s) = ""
prettyV' (BEntity name id list) = "@"++name ++"{"++id++",\n" ++ (value list) ++ "\n}\n"
	where   value [] = ""
		value ((BibValue k v):xs) = "\t"++k ++ "= \"" ++ v ++ "\",\n" ++ (value xs)

prettyPrint :: [BibTeXType] -> IO ()
prettyPrint [] = putStrLn ""
prettyPrint (x:xs) = do
	putStrLn $ prettyV' x;
	prettyPrint xs
